﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ViewBranch : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (isLogin())
        {
            if (LoginedStaff.tblRole.Role != "Admin")
                Response.Redirect("~/Admin/Index.aspx");
        }
        else
        {
            Response.Redirect("~/Admin/Stafflogin.aspx");
        }
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Del")
        {
            int id = Convert.ToInt32(e.CommandArgument);
            MailDistributionSystemDBDataContext db = new MailDistributionSystemDBDataContext();
            tblBranch t = db.tblBranches.SingleOrDefault(c => c.ID == id);
            db.tblBranches.DeleteOnSubmit(t);
            db.SubmitChanges();

            SqlDataSource1.DataBind();
            GridView1.DataBind();
        }
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

}